package com.ctshk.app.localfun.controller;

import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.localfun.req.LocalFunQueryReq;
import com.ctshk.rpc.localfun.req.cache.LocalFunProductCacheOpsReq;
import com.ctshk.rpc.localfun.req.cache.RemainderNumOpsReq;
import com.ctshk.rpc.localfun.service.ILocalFunAppProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @Description 当地玩乐-产品中心
 * @Author wansi <gaylen15527491065@yeah.net>
 * @Date 2021/3/24
 */
@RestController
@RequestMapping("/local-fun-product/cache")
@Api(value = "当地玩乐-C端前端控制器",tags = "当地玩乐-產品信息")
public class LocalFunProductCacheController extends BaseController {

    @DubboReference
    private ILocalFunAppProductService iLocalFunAppProductService;

    @ApiOperation(value="", notes="當地玩樂-缓存初始化",tags = "当地玩乐-缓存初始化")
    @OperationLogAnnotation(operModul = OperationLogModel.LOCALFUN, operType = OperationLogType.ADD, operTitle = "当地玩乐-缓存初始化", operDesc = "當地玩樂-缓存初始化")
    @PostMapping("/init")
    public Result cacheInit(){
       return iLocalFunAppProductService.cacheInit();
    }

    @ApiOperation(value="", notes="當地玩樂-缓存更新",tags = "当地玩乐-缓存更新")
    @OperationLogAnnotation(operModul = OperationLogModel.LOCALFUN, operType = OperationLogType.UPDATE, operTitle = "当地玩乐-缓存更新", operDesc = "當地玩樂-缓存更新")
    @PostMapping("/update")
    public Result cacheUpdate(@RequestBody @Valid LocalFunProductCacheOpsReq req){
        return Result.success(iLocalFunAppProductService.cacheUpdate(req));
    }

    @ApiOperation(value="", notes="當地玩樂-剩余票数操作",tags = "当地玩乐-剩余票数操作")
    @OperationLogAnnotation(operModul = OperationLogModel.LOCALFUN, operType = OperationLogType.UPDATE, operTitle = "当地玩乐-剩余票数操作", operDesc = "當地玩樂-剩余票数操作")
    @PostMapping("/remainderops")
    public Result remainderNumberOps(@RequestBody @Valid RemainderNumOpsReq req ){
        return Result.success(iLocalFunAppProductService.remainderNumberOps(req));
    }

}
